﻿using Android.App;
using Android.Content;

namespace StockTradTest.Droid
{
    [BroadcastReceiver]
    [IntentFilter(new[] { Intent.ActionBootCompleted })]
    public class BootReceiver : BroadcastReceiver
    {
        public override void OnReceive(Context context, Intent intent)
        {
            //throw new System.NotImplementedException();
            //Toast.MakeText(context, "test", ToastLength.Short).Show();
            Intent _intent = new Intent();
            _intent.SetClass(context, typeof(MainActivity));
            _intent.SetFlags(ActivityFlags.NewTask);
            context.StartActivity(_intent);
        }
    }
    //广播接收器，标题
    [BroadcastReceiver]
    public class AlarmHandler : BroadcastReceiver
    {
        //当接收时：环境，媒介信使
        public override void OnReceive(Context context, Intent intent)
        {
            if (intent?.Extras != null)
            {
                //获取信息
                string title = intent.GetStringExtra(AndroidNotificationManager.TitleKey);
                string message = intent.GetStringExtra(AndroidNotificationManager.MessageKey);
                //显示
                AndroidNotificationManager.Instance.Show(title, message);
            }
        }
    }
}
